package com.youpai.platform.file.web;

import com.youpai.platform.common.entity.resp.BaseResponse;
import com.youpai.platform.file.service.entity.resp.FileUploadResp;
import com.youpai.platform.file.service.service.FileService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;

/**
 * @author welles
 * @version 1.0
 * @description 文件相关controller
 * @date 2021/11/11
 */
@Slf4j
@RestController
@RequestMapping(value = "/file")
@Api(value = "FileController", tags = "文件相关")
public class FileController {

    @Resource
    private FileService fileService;

    @ApiOperation(value = "文件上传")
    @PostMapping(value = "/upload")
    public BaseResponse<FileUploadResp> uploadFile(@RequestParam("file") MultipartFile file){
        return BaseResponse.success(fileService.uploadFile(file));
    }
}
